<template>
	<view class="">
		<view class="margin-top-sm">
			<!-- 搜索框 -->
			<view style="margin-top: 20rpx;display: flex;">
				<view style="width: 150rpx;margin: 0rpx 10px;">
					<button class="login-btn cu-btn block bg-white" @click="showMore">更多</button>
				</view>
				<view style="flex: 1;margin: 0rpx 10px;">
					<uni-easyinput ConfirmType="search" type="text" suffixIcon="search" confirmType="search"
						v-model="queryFrom.student_name" placeholder="学生姓名" @iconClick="init" @confirm="init">
						<view v-slot='right'>
							asdf
						</view>
					</uni-easyinput>
				</view>
				<view style="width: 150rpx;margin: 0rpx 10px;">
					<button class="login-btn cu-btn block bg-blue" @click="init">查询</button>
				</view>
			</view>
		</view>

		<view class="font-12 juzhong navbar " style="color: #999;padding: 10rpx;" v-if="total>0">
			第{{queryFrom.pageNo}}页，共计{{total}}条
		</view>
		<view v-if="list.length==0" class="margin-top-sm">
			<blues-empty img="msg" text="暂无数据">

			</blues-empty>
		</view>
		<view :class="{'bg-white  padding-sm  margin-bottom-sm':true}" v-for="item in list">
			<view style="z-index:3;position: relative;">
				<view style="display: flex;justify-content: space-between;">
					<view>
						<view style="font-weight: bold;">{{item.customerModel.student.name}}</view>
						<view class="font-12 margin-top-xs">
							{{item.status==1?'已测评':'未测评'}}&nbsp;&nbsp;|&nbsp;&nbsp;{{$getDictNameByValue('invitation_purpose', item.invitationPurpose)}}&nbsp;&nbsp;|&nbsp;&nbsp;
							{{ $getDictNameByValue('grade', item.evaluationGrade) }}&nbsp;&nbsp;|&nbsp;&nbsp;Kitty
						</view>
					</view>

					<view style="text-align: right;">
						<view class="margin-right-xs font-12" style="z-index: 3;">
							查看详情<uni-icons type="right" size="12"></uni-icons>
						</view>
						<view class="font-11 margin-top-sm" style="color: #999;">
							邀约时间:&nbsp;&nbsp;{{item.invitationTime}}<br>
						</view>
					</view>


				</view>


				<view style="height: 1px;background-color: #ededed;margin: 10rpx 0px;"></view>
				<view style="display: flex;z-index: 3;" class="margin-top-sm">
					<view style="width: 150rpx;" class="" @click="download(item,2)">
						<view style="" class="juzhong">
							<view class="vabiconborder bg-blue " style="width: 60rpx;height: 60rpx;">
								<vab-icon class="vab-icon" :icon="['fas', 'file-pdf']"
									:style="{color:'#fff'}"></vab-icon>
							</view>

						</view>
						<view class=" font-11 margin-top-xs juzhong">下载测评表</view>
					</view>



					<view style="width: 150rpx;" @click="doAdd(item)">
						<view style="" class="juzhong">
							<view class="vabiconborder bg-blue " style="width: 60rpx;height: 60rpx;">
								<vab-icon class="vab-icon" :icon="['fas', 'pen']" :style="{color:'#fff'}"></vab-icon>
							</view>

						</view>
						<view class=" font-11 margin-top-xs juzhong">测评</view>
					</view>

					<view style="width: 150rpx;" class="" v-if="item.status==1" @click="download(item,1)">
						<view style="" class="juzhong">
							<view class="vabiconborder bg-blue juzhong" style="width: 60rpx;height: 60rpx;">
								<vab-icon class="vab-icon" :icon="['fas', 'file-pdf']"
									:style="{color:'#fff'}"></vab-icon>
							</view>

						</view>
						<view class=" font-11 margin-top-xs juzhong">下载测报告</view>
					</view>


				</view>
			</view>
		</view>

		<!-- 查询更多 -->
		<customerQuery @refresh="init" ref="customerQuery">
			<template v-slot:default="slotProps">
				<uni-forms-item label="测评状态">
					<uni-data-checkbox style="width: 100%;" mode="button" v-model="queryFrom.status_EQ"
						:localdata="[{text:'已测评',value:1},{text:'未测评',value:0}]"></uni-data-checkbox>
				</uni-forms-item>

			</template>

		</customerQuery>

	</view>

</template>

<script>
	import config from '@/config'
	import {
		getList,
	} from "@/api/marketing/evaluation/AxEvaluationRecordManagementApi.js";
	import {
		isNull
	} from '@/utils/validate'
	import customerQuery from "@/pages/common/customerQuery/customerQuery.vue"
	export default {


		components: {
			customerQuery,

		},
		data() {
			return {
				queryFrom: {
					pageNo: 1,
					pageSize: 10,
					startus_EQ: null,

					createTime_ORDER: "DESC",
					customerId_EQ: null,
				},
				total: 0,
				list: []
			}
		},
		mounted() {

		},
		onLoad(op) {
			if (op.customerId != null) {
				this.queryFrom.customerId_EQ = op.customerId
			}
			this.init()
		},
		// 触底事件 - 上拉加载
		onReachBottom() {
			// 加判断： 页码数 * 每一页获取数据的条数 >= 总条数，如果符合条件说明数据已经全部加载完毕
			if (this.queryFrom.pageNo * this.queryFrom.pageSize >= this.total) {

				return
			} else {

				this.queryFrom.pageNo++ // 每触发一次触底事件，页码加1
				this.listAdd() // 请求接口，获取数据  
			}
		},
		methods: {
			doAdd(row) {
				console.log(typeof row.evaluationGrade)
				if (row.evaluationGrade == "98") {
					var muban = 'xq'
				} else if (row.evaluationGrade == "99" || row.evaluationGrade == "1") {
					var muban = 'xlq'
				} else if (row.evaluationGrade > 1 && row.evaluationGrade < 10) {
					var muban = 'xs'
				} else {
					this.$baseMessage('找不到学生年级模板', 'error')
				}

				uni.navigateTo({

					url: "/pages/marketing/evaluation/muban/" + muban + "?id=" + row.id
				})
			},
			showMore() {
				this.$refs["customerQuery"].open(this.queryFrom);
			},


			download(row, index) {
				var adfas1 = ''
				var adfas2 = ''
				if (index == 1) {
					var mymessage = confirm("需要同时发送至家长微信吗?");
					if (mymessage == true) {

					} else {

					}

					this.index = 1
					this.getProgress(config.baseUrl + "/" + row.evaluationPlanUrl, row.evaluationPlanUrl.split('/')[row
						.evaluationPlanUrl.split('/').length - 1], adfas1)
				} else {
					this.getProgress(config.baseUrl + "/" + row.evaluationFormParentUrl, row.evaluationFormParentUrl.split(
						'/')[
						row.evaluationFormParentUrl.split('/').length - 1], adfas1)

				}


			},
			getProgress(url, aa) {
				window.open(url, '_blank');

			},
			init() {
				this.list = []
				this.total = 0
				this.queryFrom.pageNo = 1
				//查询合同信息
				this.fetchData()
			},
			listAdd() {
				//查询合同信息
				this.fetchData()
			},
			async fetchData() {
				const {
					data
				} = await getList(this.queryFrom);
				if (!isNull(data)) {
					for (let s of data.rows) {
						this.list.push(s)
					}
					this.total = data.total;
				}

			},

		}
	}
</script>

<style>
	.navbar {

		width: 100%;


		background-color: #f1f1f1;
		z-index: 4;
		text-align: center;

		/* 兼容 */

		position: -webkit-sticky;

		position: -ms-sticky;

		position: -o-sticky;

		/* 粘性定位*/

		position: sticky;

		left: 0;

		top: 0
	}

	.vabiconborder {
		width: 140rpx;
		height: 80rpx;
		padding: 5rpx;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		border-radius: 3px;
		background-color: $uni-color-primary;
	}
</style>